//TN256模组数据转换模块，把两个时钟数据拼凑成一个14bits灰度数据
module tn256_data_cvnt(
	input clk,
	input rst_n,
	input hs,vs,
	input [7:0] idata,
	output [13:0] odata,
	output hsync,vsync,de
);
reg hsync_r,hsync_r0,vsync_r,vsync_r0,de_r,de_r0;
reg [13:0] odata_r;
assign hsync = hsync_r;
assign vsync = vsync_r;
assign de    = de_r;
assign odata = ~odata_r;//黑热转白热，探测器默认是黑热（越热物体响应值越低）
always@(posedge clk or negedge rst_n)
begin
if(!rst_n)
    begin
	hsync_r  <= 1'b0;
	vsync_r  <= 1'b0;
	hsync_r0 <= 1'b0;
	vsync_r0 <= 1'b0;
	de_r     <= 1'b0;
	de_r0    <= 1'b0;
	odata_r  <= 14'd0;
	end
else
    begin
	if(hs && vs)
	    de_r0 <= ~de_r0;
    else
	    de_r0 <= 1'b0;
	de_r <= de_r0;
    if(hs && vs)
	    odata_r <= {odata_r[5:0],idata};
	else
	    odata_r <= 14'd0;
	hsync_r0 <= hs;
	hsync_r  <= hsync_r0;
	vsync_r0 <= vs;
	vsync_r  <= vsync_r0;
	end
end
endmodule 